<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link type="text/css" rel="stylesheet" href="css/style.css" />
    <!--[if IE 6]>
    <script src="js/iepng.js" type="text/javascript"></script>
    <script type="text/javascript">
        EvPNG.fix('div, ul, img, li, input, a');
    </script>
    <![endif]-->
    <script type="text/javascript" src="js/jquery-1.11.1.min_044d0927.js"></script>
    <script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="js/menu.js"></script>

    <script type="text/javascript" src="js/select.js"></script>

    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="http://unpkg.com/axios/dist/axios.min.js"></script>

    <script type="text/javascript" src="js/a_adminAddress.js"></script>
    <title>易买网</title>
</head>
<body>
<!--Begin Header Begin-->
<div id="tou">

</div>

<!--End Header End-->
<div class="i_bg bg_color">
    <!--Begin 用户中心 Begin -->
    <div class="m_content">
        <div class="m_left">
            <div class="left_n">管理中心</div>
            <div class="left_m">
                <div class="left_m_t t_bg1">订单中心</div>
                <ul>
                    <li><a href="adminOrder.html">我的订单</a></li>
                    <li><a href="adminOrder.html?user=admin">全部订单</a></li>
                </ul>
            </div>
            <div class="left_m">
                <div class="left_m_t t_bg2">会员中心</div>
                <ul>
                    <li><a href="admin.html">用户信息</a></li>
                    <li><a href="adminUserList.html">用户列表</a></li>
                    <li><a href="adminCollect.html">我的收藏</a></li>
                </ul>
            </div>
            <div class="left_m">
                <div class="left_m_t t_bg4">分销中心</div>
                <ul>
                    <li><a href="adminCategory.html">分类管理</a></li>
                    <li><a href="adminProManage.html">商品管理</a></li>
                    <li><a href="adminAddProduct.html">新增商品</a></li>
                </ul>
            </div>
            <div class="left_m">
                <div class="left_m_t t_bg3">咨询中心</div>
                <ul>
                    <li><a href="adminNews.html">咨询列表</a></li>
                    <li><a href="adminAddress.html">地址维护</a></li>
                </ul>
            </div>
        </div>

        <div class="m_right" id="app">
            <div class="mem_tit">
                资讯列表
                <a href="javascript:;"  id="addNews" style="background-color: rgb(255, 78, 0);color: rgb(255, 255, 255);float: right;width: 80px;height: 30px;line-height: 30px;margin: 13px;text-align: center;">新增新闻</a>
            </div>
            <table style="width: 100%" >
                <tr>
                    <th>文章标题</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
                <tr v-for="item in info.list" style="text-align: center;line-height: 50px" :data-id="item.id">
                    <td>{{item.title}}</td>
                    <td>{{item.createtime}}</td>
                    <td>
                        <a href="javascript:;" @click="deleteNews(item.id)" :data-id="item.id">删除</a>
                        <a href="javascript:;" :data-id="item.id" @click="updateNews(item.id)">修改</a>
                    </td>
                </tr>
            </table>
            <div class="pages">
                <a class="p_pre" @click="getPage(info.navigateFirstPage,info.pageSize)">首页</a>
                <a class="p_pre" @click="prePage" v-if="info.pageNum>1">上一页</a>
                <a v-for="page in info.navigatepageNums" :class="{cur:currentIndex === page}" @click="number(page)">{{page}}</a>
                <a class="p_pre" @click="nextPage" v-if="info.pageNum<info.pages">下一页</a>
                <a class="p_pre" @click="getPage(info.navigateLastPage,info.pageSize)">末页</a>
            </div>
        </div>
    </div>

    <script>
        var vm=new Vue({
            el:"#app",
            data(){
                return{
                    info:{

                    },
                    currentIndex:1,
                    message:""
                }
            },
            methods:{
                //上一页
                prePage:function () {
                    if (this.info.pageNum == 1) return;
                    this.info.pageNum--;
                    this.currentIndex=this.info.pageNum;
                    this.getPage(this.info.pageNum,this.info.pageSize);
                },
                //下一页
                nextPage:function () {
                    if (this.info.pageNum == this.info.pages) return;
                    this.info.pageNum++;
                    this.currentIndex=this.info.pageNum;
                    this.getPage(this.info.pageNum,this.info.pageSize);
                },
                getPage:function (pageNum,pageSize) {
                    this.currentIndex=pageNum;
                    axios.get("easybuy/newsPage",{
                        params:{
                            pageNum:pageNum,
                            pageSize:pageSize
                        }
                    }).then(response=>this.info=response.data)
                },
                //数字跳转
                number:function (page) {
                    this.currentIndex=page;
                    this.getPage(page,10);
                },
                //删除新闻
                deleteNews:function (id) {
                    if (confirm("是否要删除该新闻")){
                        axios.get("easybuy/deleteNews?id="+id).then(function (response) {
                            console.log(response.data);
                            if (response.data=="success"){
                                vm.getPage(1,10);
                            }
                        });
                    }

                },
                //跳到新闻修改页面
                updateNews:function (id) {
                    // location.href="adminupdateNews.html?id="+id;
                    $("#app").empty();
                    $("#app").append("<p></p>\n" +
                        "\n" +
                        "<div class=\"mem_tit\" style=\"text-align: center\">\n" +
                        "                修改新闻\n" +
                        "            </div>\n" +
                        "            <table border=\"0\" class=\"mem_tab\" style=\"width:930px; margin-bottom:30px;\" cellspacing=\"0\" cellpadding=\"0\">\n" +
                        "                <tr>\n" +
                        "                    <td width=\"150\" class=\"tx_l\">标题</td>\n" +
                        "                    <td width=\"680\">\n" +
                        "                        <input type=\"text\" value=\"\" class=\"tx_ipt\" name=\"title\"/>\n" +
                        "                        <font style=\"color: red\">(*标题必须唯一)</font>\n" +
                        "                    </td>\n" +
                        "                </tr>\n" +
                        "                <tr valign=\"top\">\n" +
                        "                    <td class=\"tx_l\">内容</td>\n" +
                        "                    <td><textarea class=\"tx_txt\" name=\"content\"></textarea></td>\n" +
                        "                </tr>\n" +
                        "                <tr height=\"70\">\n" +
                        "                    <td colspan=\"2\" align=\"center\">\n" +
                        "                        <input type=\"button\" value=\"修改\" class=\"btn_tj\" id=\"updateNews\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n" +
                        "                        <input type=\"button\" value=\"返回\" class=\"btn_tj\" id=\"back\"/>\n" +
                        "                    </td>\n" +
                        "                </tr>\n" +
                        "            </table>");

                    //返回
                    $("#back").click(function () {
                        location.href="adminNews.html";
                    });
                    //判断标题是否唯一
                    $("[name='title']").change(function () {
                        var title = $("[name='title']").val();
                        $.ajax({
                            url: "easybuy/isTitle",
                            data: {
                                title: title
                            },
                            success: function (data) {
                                if (data=="failed"){
                                    alert("标题重复，请重新填写！");
                                    $("[name='title']").val("");
                                }
                            }
                        });
                    });
                    //新闻内容显示
                    $.ajax({
                        url: "easybuy/selectNewsByID",
                        data:{
                            id:id
                        },
                        success:function (data) {
                            $("[name='title']").val(""+data.title+"");
                            $("[name='content']").text(""+data.content+"");
                        }
                    });
                    //修改新闻
                    $("#updateNews").click(function () {
                        var title = $("[name='title']").val();
                        var content = $("[name='content']").val();
                        $.ajax({
                            url: "easybuy/updateNews",
                            data:{
                                id:id,
                                title:title,
                                content:content
                            },
                            success:function (data) {
                                if (data=="success"){
                                    alert("修改成功！");
                                    location.href="adminNews.html";
                                }else {
                                    alert("修改失败,请联系管理员！");
                                }
                            }
                        })
                    })
                }

            },
            mounted(){
                axios.get("easybuy/newsPage?pageNum=1&pageSize=10").then(response=>this.info=response.data)
            },
        });
    </script>

    <!--End 用户中心 End-->
    <!--Begin Footer Begin -->
    <div class="b_btm_bg b_btm_c">
        <div class="b_btm">
            <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="72"><img src="images/b1.png" width="62" height="62" /></td>
                    <td><h2>正品保障</h2>正品行货  放心购买</td>
                </tr>
            </table>
            <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="72"><img src="images/b2.png" width="62" height="62" /></td>
                    <td><h2>满38包邮</h2>满38包邮 免运费</td>
                </tr>
            </table>
            <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="72"><img src="images/b3.png" width="62" height="62" /></td>
                    <td><h2>天天低价</h2>天天低价 畅选无忧</td>
                </tr>
            </table>
            <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="72"><img src="images/b4.png" width="62" height="62" /></td>
                    <td><h2>准时送达</h2>收货时间由你做主</td>
                </tr>
            </table>
        </div>
    </div>
    <div class="b_nav">
        <dl>
            <dt><a href="#">新手上路</a></dt>
            <dd><a href="#">售后流程</a></dd>
            <dd><a href="#">购物流程</a></dd>
            <dd><a href="#">订购方式</a></dd>
            <dd><a href="#">隐私声明</a></dd>
            <dd><a href="#">推荐分享说明</a></dd>
        </dl>
        <dl>
            <dt><a href="#">配送与支付</a></dt>
            <dd><a href="#">货到付款区域</a></dd>
            <dd><a href="#">配送支付查询</a></dd>
            <dd><a href="#">支付方式说明</a></dd>
        </dl>
        <dl>
            <dt><a href="#">会员中心</a></dt>
            <dd><a href="#">资金管理</a></dd>
            <dd><a href="#">我的收藏</a></dd>
            <dd><a href="#">我的订单</a></dd>
        </dl>
        <dl>
            <dt><a href="#">服务保证</a></dt>
            <dd><a href="#">退换货原则</a></dd>
            <dd><a href="#">售后服务保证</a></dd>
            <dd><a href="#">产品质量保证</a></dd>
        </dl>
        <dl>
            <dt><a href="#">联系我们</a></dt>
            <dd><a href="#">网站故障报告</a></dd>
            <dd><a href="#">购物咨询</a></dd>
            <dd><a href="#">投诉与建议</a></dd>
        </dl>
        <div class="b_tel_bg">
            <a href="#" class="b_sh1">新浪微博</a>
            <a href="#" class="b_sh2">腾讯微博</a>
            <p>
                服务热线：<br />
                <span>400-123-4567</span>
            </p>
        </div>
        <div class="b_er">
            <div class="b_er_c"><img src="images/er.gif" width="118" height="118" /></div>
            <img src="images/ss.png" />
        </div>
    </div>
    <div class="btmbg">
        <div class="btm">
            备案/许可证编号：蜀ICP备12009302号-1-www.dingguagua.com   Copyright © 2015-2018 尤洪商城网 All Rights Reserved. 复制必究 , Technical Support: Dgg Group <br />
            <img src="images/b_1.gif" width="98" height="33" /><img src="images/b_2.gif" width="98" height="33" /><img src="images/b_3.gif" width="98" height="33" /><img src="images/b_4.gif" width="98" height="33" /><img src="images/b_5.gif" width="98" height="33" /><img src="images/b_6.gif" width="98" height="33" />
        </div>
    </div>
    <!--End Footer End -->
</div>

</body>


<!--[if IE 6]>
<script src="//letskillie6.googlecode.com/svn/trunk/2/zh_CN.js"></script>
<![endif]-->
</html>
